/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package kcollgen;

import java.util.ArrayList;

/**
 *
 * @author Pierre
 */
public class CollectionJson {
    
    ArrayList<Collection> collections;

    public CollectionJson() {
        collections = new ArrayList<Collection>();
    }
    
    void addCol(String colName){
        for(Collection c : collections)
            if(c.colName.equals(colName)){
                System.out.println("Error : Collection " + colName 
                        + " already existing");
                return;
            }
        Collection col = new Collection(colName);
        collections.add(col);
    }
    
    void addSha1ToCol(String colName, String sha1){
        for(Collection c : collections)
            if(c.colName.equals(colName)){
                c.addSha1(sha1);
                return;
            }
        System.out.println("Error : collection " + colName + " not found");
    }
    
    String getKindleOutputBuffer(){
        String res = "";
        
        res+= "{";
        
        for(Collection c : collections){
            res += c.getKindleString();
            if(collections.indexOf(c) != collections.size()-1)
                res += ",";
        }
        
        res += "}";
        
        return res;
    }
}
